package com.xyyl.patient.mapper.doctor;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.xyyl.patient.core.mapper.GenericMapper;
import com.xyyl.patient.entity.doctor.Doctor;
import com.xyyl.patient.entity.question.DoctorEvaluate;

/**
 * @projectName:xyyl-patient-service
 * @ClassName: DoctorMapper
 * @Description: 医生信息Mapper
 * @author chengjun
 * @date 2017年8月18日
 *
 */
public interface DoctorMapper extends GenericMapper{
    public List<Doctor> queryForPage();
    public List<DoctorEvaluate> getDoctorEvaluate(Integer doctorId);

    public String getDoctorIMEI(Integer doctorId);
    
    @Select("SELECT t.bookdate,t.booktime FROM xyyl_doctor_booktime t WHERE  t.doctorid=#{doctorid}")
    public List<Map<String,Object>> getBookTimeByDoctorId(@Param(value="doctorid") Integer doctorid);
     
    @Select("SELECT t.deviceNumber FROM xyyl_doctor_login_log t WHERE t.doctorid=#{doctorid} ORDER BY t.logintime DESC LIMIT 1")
    public String getDoctorDeviceTokensById(@Param(value="doctorid") Integer doctorid);
    
    @Select("SELECT doctor.id FROM xyyl_doctor doctor WHERE speedphoneisopen=1")
	public List<Doctor> queryDoctorListOfSpeedPhoneOrder();

	@Select("SELECT u.mobile FROM  xyyl_doctor t, sys_user u  WHERE  t.sysuserid=u.id AND  t.id=#{doctorid}")
	String queryDoctorMoblieById(@Param("doctorid") Integer doctorid);

    @Select("SELECT * FROM  xyyl_doctor   WHERE  id=#{doctorid}")
    Doctor getDoctorinfo(@Param("doctorid") Integer doctorid);

    @Select("SELECT xyyl_hospitalinfo.* from xyyl_doctor INNER JOIN xyyl_hospitalinfo on xyyl_doctor.hospitalid = xyyl_hospitalinfo.id GROUP BY xyyl_hospitalinfo.id")
    public List<Map<String,Object>> getHosp();

    @Select("SELECT * from xyyl_hospital_dept  GROUP BY `name`")
    public List<Map<String,Object>> getDept();

    @Select("SELECT * from xyyl_hospital_dept WHERE hospitalid =#{hospitalid}")
    public List<Map<String,Object>> getDeptByHosId(@Param("hospitalid") Integer hospitalid);

	public void updateDoctorConcern(Map<String, Object> map);
}